package com.mapreduce;

import com.bean.YearTemp;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Partitioner;

public class YearPar extends
        Partitioner<YearTemp, IntWritable> {
    @Override
    public int getPartition(YearTemp yearTemp, IntWritable intWritable, int numPartitions) {
        // 使年份相同的数据放到同一个分区下
        return (yearTemp.getYear().hashCode())
                *127%numPartitions;
    }
}
